<?php

namespace app\admin\model;

class MidModel extends BaseModel
{
    public static function countRaningNum($rmap,$ranting=0)
    {
        $count = SportRecord::where($rmap)->where('rating',$ranting)->group('memberId')->count('*');
        return $count;
    }
    /**
     * 获取缓存信息
     * @param int $id 记录ID
     * @return \app\common\model\数据信息|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @author 牧羊人
     * @since: 2023/09/01
     */
    public function getInfo222($id)
    {
        $info = parent::getInfo($id); // TODO: Change the autogenerated stub
        $post = input();
        $stu_map = [
            'status' => 1,
            'mark' => 1,
            'superior' => $id,
        ];
        $rmap[] = ['projectId','=',$id];

       if(isset($post['professionalId'])){
            $prof = Professional::get(input('professionalId'));
            $info['prof_name']= $prof?$prof['name']:'';
        }

        if(isset($post['departmentsId'])){
            $depart = Department::get(input('departmentsId'));
            $info['depart_name']= $depart?$depart['name']:'';
        }

        if(isset($post['projectId'])){
            $pro = Project::get(input('projectId'));
            $info['pro_name']= $pro?$pro['name']:'';
        }
        if(isset($post['gradeId'])){
            $grade = Grade::get(input('gradeId'));
            $info['grade_name']= $grade?$grade['name']:'';
            $stu_map+=[
                'grade' => $post['gradeId'],
            ];
            $rmap[] = ['gradeId','=', $post['gradeId']];
        }

        $avg = 0;
        if(isset($post['startTime']) && isset($post['endTime'])){
            $rmap[] = ['startTime','>', $post['startTime']];
            $rmap[] = ['startTime','<', $post['endTime']];
        }
        if(isset($post['hasTest'])){
            $rmap[] = ['hasTest','=',$post['hasTest']];
        }
        if(isset($post['annual'])){
            $rmap[] = ['startTime','>', Annual::getTimeArr($post['annual'])[0]];
            $rmap[] = ['startTime','<', Annual::getTimeArr($post['annual'])[1]];
        }

        //professionalId
        $avg = SportRecord::where($rmap)->avg('score');
        $count = Memb::where($stu_map)->count();
        $info['number'] = (int)$count;
        $info['avg'] = (int)$avg;

        $info['goodNum'] = 0;
        $info['liangNum'] = 0;
        $info['jigeNum'] = 0;
        $info['noJigeNum'] = 0;
        $info['youRate'] = 0;
        $info['hegeRate'] = 0;

        if ($info) {

        }
        return $info;
    }



}